﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using BUS;

public partial class UserControl_MenuTrangChu : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadMenu();
    }
    private void LoadMenu()
    {
        List<LoaiSanPham> lsp = new LoaiSanPhamBUS().LayLoaiSanPham();
        for (int i = 0; i < lsp.Count; i++)
        {
            AjaxControlToolkit.AccordionPane accp = new AjaxControlToolkit.AccordionPane();
            Label lblHeader = new Label();
            lblHeader.ID = "lblHead" + i.ToString();
            lblHeader.Text = "<a href='#'>" + lsp[i].TenLoaiSanPham.ToString() + "</a>";
            List<HangSanXuat> hsx = new HangSanXuatBUS().LayTenHangSanXuat(i + 1);
            Label lblContent = new Label();
            lblContent.ID = "lblContent" + i.ToString();
            lblContent.Text = "";
            accp.ID = "accp" + i.ToString();
            for (int j = 0; j < hsx.Count; j ++)
            {
                lblContent.Text += "<a href='Default.aspx?HSXID=" + hsx[j].MaHangSX + "'>" + hsx[j].TenHangSX.ToString() + "</a><br>";
            }
            accp.HeaderContainer.Controls.Add(lblHeader);
            accp.ContentContainer.Controls.Add(lblContent);
            Accordion1.Panes.Add(accp);
        }
    }
}